package com.dfec.book.constant;


/**
 * 归还状态
 * @author tangrg
 * @email 1446232546@qq.com
 * @date 2025-06-19 10:06:37
 */
public enum BorrowStatusEnum {

    // @formatter:off
    RETURN_YES(0, "归还"),
    RETURN_NO(1, "未还"),
    UNKNOWN(999, "未知");
    // @formatter:on

    /**
     * 错误代码
     */
    private final int code;

    /**
     * 错误信息
     */
    private final String name;

    BorrowStatusEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code获取枚举常量
     * @param code 要素代码
     * @return 常量
     */
    public static BorrowStatusEnum of(int code) {
        for (BorrowStatusEnum value : values()) {
            if (value.code==code) {
                return value;
            }
        }
        return UNKNOWN;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}
